package com.yihu.wlyy.repository;

import com.yihu.wlyy.entity.WlyyDoctorWorkWeek;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by lyr on 2016/08/19.
 */
public interface DoctorWorkWeekDao extends PagingAndSortingRepository<WlyyDoctorWorkWeek, Long>, JpaSpecificationExecutor<WlyyDoctorWorkWeek> {

    /**
     * 查询医生排班列表
     *
     * @param doctor
     * @return
     */
    @Query("select a from WlyyDoctorWorkWeek a where a.doctor = ?1")
    List<WlyyDoctorWorkWeek> findDoctorWorkWeeks(String doctor);

    /**
     * 查询医生某天排班信息
     *
     * @param doctor
     * @param week
     * @return
     */
    @Query("select a from WlyyDoctorWorkWeek a where a.doctor = ?1 and a.week = ?2")
    WlyyDoctorWorkWeek findDoctorWorkWeek(String doctor,String week);

    /**
     * 删除医生的排班信息
     *
     * @param doctor
     */
    void deleteByDoctor(String doctor);
}
